<template>
  <div class="box">
    <div class="header">
      <div class="title">
        {{ title }}
        <span class="date" v-if="date">{{ star + '～' + now }}</span>
      </div>
      <slot name="tool"></slot>
    </div>
    <slot name="subtool"></slot>
    <div class="body" :class="{ colum }">
      <slot :list="list">
        <div class="empty show">
          <img :src="emptSrc" />
          <div class="tips">暂无数据</div>
        </div>
      </slot>
    </div>
  </div>
</template>

<script>
import moment from 'moment'
export default {
  name: 'task-comp',
  components: {},
  props: {
    title: {
      type: String,
      require: true
    },
    date: {
      type: Boolean,
      default: false
    },
    colum: {
      type: Boolean,
      default: false
    },
    list: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      emptSrc: 'http://likede2-admin.itheima.net/img/empty.87c4f71b.png'
    }
  },
  computed: {
    star() {
      return moment().format('YYYY.MM.01')
    },
    now() {
      return moment().format('YYYY.MM.DD')
    }
  },
  watch: {},
  methods: {}
}
</script>

<style lang="scss" scoped>
.box {
  flex: 1;
  padding: 20px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  background-color: #fff;
  .header {
    display: flex;
    .title {
      flex: 1;
      align-self: center;
      font-size: 16px;
      font-weight: 600;
      color: #333;
      .date {
        margin-right: 10px;
        color: #999999;
        font-size: 12px;
      }
    }
  }
  .body {
    flex: 1;
    display: flex;
    .empty {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
  }
  .colum {
    flex-direction: column;
    justify-content: space-around;
  }
}
</style>
